package game;

/*
 * timer to make stable fps in game
 */

public class Timer extends Thread implements Runnable {
	private int sl;
	int frames;
	
	public Timer(int frames) throws BadugiException {
		if (frames<1 || frames>1000) {
			throw new BadugiException("wrong number of fps");
		}
		sl=1000/frames;
		this.frames=0;
	}

	@Override
	public void run() {
		while(true) {
			frames++;
			try {
				sleep(sl);
			} catch (InterruptedException e) {
			}
		}
	}
}
